package dao;

import dataBean.CourseInfoDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by lxl on 2015/10/18.
 */
public interface CourseInfoDao {

    @Insert("insert into course_info(teacher_id,gp,name)values(#{teacherId},#{gp},#{name})")
    public int insertCourseInfo( CourseInfoDo courseInfoDo) ;

    @Select("select * from course_info where id=( select course_id from scores where id = #{id} )")
    public CourseInfoDo selectCourseByScoreId(int id) ;

    @Select("select * from  course_info where teacher_id = (select  id from user_info where username =#{username})")
    public List<CourseInfoDo> selectCourseByTeacherUserName( String username ) ;

    @Select("select teacher_id from course_info where id=#{id}")
    public int selectTeacherId( int id ) ;

    @Select("select * from course_info where teacher_id=( select id from user_info where username=#{username})")
    public List<CourseInfoDo> selectIdsByUsername( String username) ;

    @Select("select * from course_info")
    public List<CourseInfoDo> selectAllCourse() ;

    @Select("select * from  course_info where id in ( select course_id from scores where user_id = (select  id from user_info where username = #{username} ))")
    public List<CourseInfoDo> selectCourseByStudentUserName( String username ) ;

}
